﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProgNetComponents.ExtenderProviders.Settings;
using System.ComponentModel;
using ProgNetComponents;
using ProgNetComponents.Design.Attributes;
using ProgNetDxComponents.ExtenderProviders.Language;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Repository;
using ProgNetComponents.ExtenderProviders;
using ProgNetDxComponents.Design.Editors;
using System.Drawing.Design;
using DevExpress.XtraEditors.Controls;
using ProgNetComponents.Design.Editors;

namespace ProgNetDxComponents.ExtenderProviders.Settings
{
    public class LanguageSettings : BaseExtenderSettings
    {
        public LanguageSettings(object owner, BaseExtenderProvider provider)
            : base(owner, provider)
        {
            _RadioGroupSettings.CollectionModified += new EventHandler(_RadioGroupSettings_CollectionModified);
        }

        void _RadioGroupSettings_CollectionModified(object sender, EventArgs e)
        {
            OnSettingsChanged();
        }

        private string _LngString;
        private string _Prefix;
        private string _Surfix;
        private string[] _Parameters;
        private string _Manager;
        private RadioItemLngInfoCollection _RadioGroupSettings = new RadioItemLngInfoCollection();
        
        [Category(Categories.Display),
        RefreshProperties(System.ComponentModel.RefreshProperties.All),
        DynamicHiddenByType("Owner", typeof(RadioGroup), typeof(RepositoryItemRadioGroup)),
        Editor(typeof(ColumnEditor), typeof(UITypeEditor))]
        public string LngString
        {
            get { return _LngString; }
            set
            {
                _LngString = value;
                if (value.IsNull())
                {
                    _Parameters = null;
                    _Prefix = null;
                    _Surfix = null;
                    _Manager = null;
                }
                OnSettingsChanged();
            }
        }
        
        [Category(Categories.Display),
        DynamicHiddenByProperty("LngString", "", null)]
        public string Manager
        {
            get { return _Manager; }
            set
            {
                _Manager = value;
                OnSettingsChanged();
            }
        }
        
        [Category(Categories.Display),
        DynamicHiddenByProperty("LngString", "", null)]
        public string Prefix
        {
            get { return _Prefix; }
            set
            {
                _Prefix = value;
                OnSettingsChanged();
            }
        }

        [Category(Categories.Display),
        DynamicHiddenByProperty("LngString", "", null)]
        public string Surfix
        {
            get { return _Surfix; }
            set
            {
                _Surfix = value;
                OnSettingsChanged();
            }
        }

        [Category(Categories.Display),
        DynamicHiddenByProperty("LngString", "", null)]
        public string[] Parameters
        {
            get { return _Parameters; }
            set
            {
                _Parameters = value;
                OnSettingsChanged();
            }
        }

        [Category(Categories.Display),
        DynamicBrowsableByType("Owner", typeof(RadioGroup), typeof(RepositoryItemRadioGroup)),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public RadioItemLngInfoCollection RadioGroupSettings
        {
            get
            {
                RadioGroupItemCollection col = null;
                if (this.Owner is RadioGroup)
                    col = (this.Owner as RadioGroup).Properties.Items;
                else if (this.Owner is RepositoryItemRadioGroup)
                    col = (this.Owner as RepositoryItemRadioGroup).Items;

                _RadioGroupSettings.Collection = col;
                return _RadioGroupSettings;
            }
        }

       
    }
   
}
